package com.ikangtai.shecare.common.baseView.pickerDialog.recordPickerDialog;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

import com.ikangtai.shecare.R;
import com.ikangtai.shecare.common.RecordFragmentCommonList;

public class BrandPickerDialog extends AlertDialog implements
        DialogInterface.OnClickListener {
    private BrandPicker mBrandPicker;
    private int brand = 1;
    private OnBrandSetListener mOnBrandSetListener;

    public BrandPickerDialog(Context context) {
        super(context);
        mBrandPicker = new BrandPicker(context);
        setView(mBrandPicker);
        /*
         *实现接口，实现里面的方法
         */
        mBrandPicker
                .setOnBrandChangedListener(new BrandPicker.OnBrandChangedListener() {
                    @Override
                    public void onTemperatureChanged(BrandPicker view, int minutes) {
                        brand = minutes;
                    }
                });

        setButton(context.getString(R.string.setting), this);
        setButton2(context.getString(R.string.cancel), (OnClickListener) null);
        setTitle(context.getString(R.string.paper_brand));
    }

    /*
     *接口回調
     *控件 秒数
     */
    public interface OnBrandSetListener {
        void OnBrandSet(AlertDialog dialog, String brand);
    }

    /*
     * 对外公开方法让Activity实现
     */
    public void setOnBrandSetListener(OnBrandSetListener callBack) {
        mOnBrandSetListener = callBack;
    }

    public void onClick(DialogInterface arg0, int arg1) {
        if (mOnBrandSetListener != null) {
            mOnBrandSetListener.OnBrandSet(this, RecordFragmentCommonList.recordOvulationPaperBrand[brand]);
        }
    }
}
